unit ufrmMain;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
  Data.DB, Vcl.StdCtrls, FireDAC.Stan.Intf, FireDAC.Stan.Option,
  FireDAC.Stan.Error, FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def,
  FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.Phys.PG,
  FireDAC.Comp.Client, FireDAC.VCLUI.Wait, FireDAC.Comp.UI, Vcl.ExtCtrls,
  segUsuario, Vcl.Menus, Vcl.ComCtrls, Vcl.ToolWin, System.Actions,
  Vcl.ActnList, Vcl.PlatformDefaultStyleActnCtrls, Vcl.ActnMan;

type
  TfrmMain = class(TForm)
    Teste: TButton;
    MainMenu1: TMainMenu;
    ToolBar1: TToolBar;
    StatusBar1: TStatusBar;
    Cadastros1: TMenuItem;
    Sobre1: TMenuItem;
    N1: TMenuItem;
    ActionManager1: TActionManager;
    Action1: TAction;
    procedure TesteClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Action1Execute(Sender: TObject);
  private
    procedure fecharFormLogin;
    procedure preencherStatusBar;

  public
    { Public declarations }
  end;

var
  frmMain: TfrmMain;

implementation

uses ufrmTesteAtributos, ufrmLogin, udmPrincipal;

{$R *.dfm}

procedure TfrmMain.FormCreate(Sender: TObject);
begin
  frmLogin := TfrmLogin.Create(Self);
  frmLogin.ShowModal;
end;

procedure TfrmMain.FormShow(Sender: TObject);
begin
  fecharFormLogin();
  preencherStatusBar();
  Sobre1.Visible := ActionManager1.Actions[0].Category = 'TODOS';
end;

procedure TfrmMain.Action1Execute(Sender: TObject);
begin
  ShowMessage('teste');
end;

procedure TfrmMain.fecharFormLogin;
begin
  if frmLogin <> nil then
    frmLogin.Close;
end;

procedure TfrmMain.preencherStatusBar;
begin
  StatusBar1.Panels.Items[0].Text := dmPrincipal.Seguranca.UsuarioLogado.Nome + ' ' + dmPrincipal.Seguranca.UsuarioLogado.SobreNome;
  StatusBar1.Panels.Items[1].Text := dmPrincipal.Seguranca.UsuarioLogado.Login;
  StatusBar1.Panels.Items[2].Text := dmPrincipal.Seguranca.UsuarioLogado.Email;
end;

procedure TfrmMain.TesteClick(Sender: TObject);
begin
  frmTesteAtributos := TfrmTesteAtributos.Create(self);
  try
    frmTesteAtributos.showmodal;
  finally
    FreeAndNil(frmTesteAtributos);
  end;
end;

end.
